package com.chen.retrofitdemo;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.Observer;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.chen.retrofitdemo.dao.UserService;
import com.chen.retrofitdemo.model.Result;
import com.chen.retrofitdemo.model.UserBean;
import com.chen.retrofitdemo.net.HttpUtils;

import retrofit2.Call;

public class MainActivity extends AppCompatActivity {

    private Button btn;
    private UserService service;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        btn=findViewById(R.id.btn);
        service = HttpUtils.getInstance(this).getClient().createService(UserService.class);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("1","111");
//               service.login().observe(MainActivity.this, new Observer<Result<String>>() {
//                   @Override
//                   public void onChanged(Result<String> stringResult) {
//                       Log.e("1","stringResult:"+stringResult.data);
//                   }
//               });

                service.login1("11122233344").observe(MainActivity.this, new Observer<Result<UserBean>>() {
                    @Override
                    public void onChanged(Result<UserBean> userBeanResult) {
                        Log.e("1","stringResult:"+userBeanResult.data.toString());
                    }
                });

            }
        });
    }
}